package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.CaseComplaintLiable;
import com.ktgj.customer.service.ICaseComplaintLiableService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 投诉工单_投诉解决责任人Controller
 * 
 * @author ruoyi
 * @date 2022-05-27
 */
@RestController
@RequestMapping("/laintLiable")
public class CaseComplaintLiableController extends BaseController
{
    @Autowired
    private ICaseComplaintLiableService caseComplaintLiableService;

    /**
     * 查询投诉工单_投诉解决责任人列表
     */
    @PreAuthorize(hasPermi = "system:liable:list")
    @GetMapping("/list")
    public TableDataInfo list(CaseComplaintLiable caseComplaintLiable)
    {
        startPage();
        List<CaseComplaintLiable> list = caseComplaintLiableService.selectCaseComplaintLiableList(caseComplaintLiable);
        return getDataTable(list);
    }

    /**
     * 导出投诉工单_投诉解决责任人列表
     */
    @PreAuthorize(hasPermi = "system:liable:export")
    @Log(title = "投诉工单_投诉解决责任人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaseComplaintLiable caseComplaintLiable) throws IOException
    {
        List<CaseComplaintLiable> list = caseComplaintLiableService.selectCaseComplaintLiableList(caseComplaintLiable);
        ExcelUtil<CaseComplaintLiable> util = new ExcelUtil<CaseComplaintLiable>(CaseComplaintLiable.class);
        util.exportExcel(response, list, "投诉工单_投诉解决责任人数据");
    }

    /**
     * 获取投诉工单_投诉解决责任人详细信息
     */
    @PreAuthorize(hasPermi = "system:liable:query")
    @GetMapping(value = "/{complaintResponsibleId}")
    public AjaxResult getInfo(@PathVariable("complaintResponsibleId") Long complaintResponsibleId)
    {
        return AjaxResult.success(caseComplaintLiableService.selectCaseComplaintLiableById(complaintResponsibleId));
    }

    /**
     * 新增投诉工单_投诉解决责任人
     */
    @PreAuthorize(hasPermi = "system:liable:add")
    @Log(title = "投诉工单_投诉解决责任人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaseComplaintLiable caseComplaintLiable)
    {
        return toAjax(caseComplaintLiableService.insertCaseComplaintLiable(caseComplaintLiable));
    }

    /**
     * 修改投诉工单_投诉解决责任人
     */
    @PreAuthorize(hasPermi = "system:liable:edit")
    @Log(title = "投诉工单_投诉解决责任人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaseComplaintLiable caseComplaintLiable)
    {
        return toAjax(caseComplaintLiableService.updateCaseComplaintLiable(caseComplaintLiable));
    }

    /**
     * 删除投诉工单_投诉解决责任人
     */
    @PreAuthorize(hasPermi = "system:liable:remove")
    @Log(title = "投诉工单_投诉解决责任人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintResponsibleIds}")
    public AjaxResult remove(@PathVariable Long[] complaintResponsibleIds)
    {
        return toAjax(caseComplaintLiableService.deleteCaseComplaintLiableByIds(complaintResponsibleIds));
    }
}
